<?php


namespace App\Service\Cache;


use App\Dao\AdminRoleDao;
use App\Model\AdminRole;
use Hyperf\Cache\Annotation\Cacheable;
use Hyperf\Di\Annotation\Inject;

class AdminRoleCache
{

    /**
     * @Inject()
     * @var AdminRoleDao
     */
    protected $adminRoleDao;

    /**
     * @Cacheable(prefix="\App\Constants\Redis\AdminRole::LIST",ttl=28800)
     */
    public function get(int $roleId)
    {
        /** @var AdminRole $adminRole */
        $adminRole =  $this->adminRoleDao->firstOrThrow(['id'=>$roleId]);
        return $adminRole->toArray();
    }
}